﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DSSLIN
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            tabControl1.Visible = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //memasukkan variabel dari datagridview1 ke dgview3
            try
            {
                for (int rows = 0; rows < dataGridView1.Rows.Count; rows++)
                {
                    for (int col = 0; col < dataGridView1.Rows[rows].Cells.Count; col++)
                    {
                        String hasil = dataGridView1.Rows[rows].Cells[col].Value + " ";
                        //textBox1.Text += hasil+ "\r\n" + " ";
                        String headername = dataGridView1.Rows[rows].Cells[0].Value + " ";

                        for (int x = 0; x < dataGridView1.Rows.Count - 1; x++)
                        {
                            dataGridView3.ColumnCount = dataGridView1.Rows.Count - 1;
                            dataGridView3.Columns[x].Name = dataGridView1.Rows[x].Cells[0].Value + " ";
                        }
                    }
                    foreach (DataGridViewRow row in this.dataGridView1.Rows)
                    {
                        DataGridViewCell cell = row.Cells[1];
                        if (cell.Value == null || cell.Value.Equals(""))
                        {
                            continue;

                        }
                        else
                        {
                            textBox1.Text = cell.Value.ToString() + "\r\n";
                        }

                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error:: " + ex.Message);
            }
            /*
            //memasukkanvariabel dari datagridview1 ke dgview3
            try
            {
                for (int rows = 0; rows < dataGridView1.Rows.Count; rows++)
                {
             
                    for (int col = 0; col < dataGridView1.Rows[rows].Cells.Count; col++)
                    {
                        String hasil = dataGridView1.Rows[rows].Cells[col].Value + " ";
                        textBox1.Text += hasil+ "\r\n" + " ";
                                                                       
                        for (int x = 0; x < dataGridView1.Rows.Count - 1; x++)
                        {
                            dataGridView3.ColumnCount = dataGridView1.Rows.Count - 1;
                            dataGridView3.Columns[x].Name = dataGridView1.Rows[x].Cells[0].Value + " ";
                            
                        }
                        for (int x = 0; x < dataGridView1.Rows.Count - 1; x++)
                        {
                          textBox2.Text += dataGridView1.Rows[x].Cells[1].Value + " ";
                           
                        }
                        
                    }
                 }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error:: " + ex.Message);
            }*/
        }

        public static void Maximum(double[,] tabel)
        {

        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            int i, j = 0;
            int mark;

            int varinitial = dataGridView1.Rows.Count - 1;
            int constraint = dataGridView2.Rows.Count - 1;
            int vartotal = varinitial + constraint;

            double[,] coef = new double[constraint, vartotal];
            double[,] bcoef = new double[constraint, 1];
            double[] ccoef = new double[vartotal];
            double[,] tabel = new double[constraint + 1, vartotal + 1];

            //variabel initial
            for (i = 0; i < constraint; i++)
            {
                //ini looh~
                foreach (DataGridViewRow row in this.dataGridView1.Rows)
                {
                    DataGridViewCell cell = row.Cells[1];
                    textBox1.Text = cell.Value.ToString();
                }
                //~~

                for (j = 0; j < varinitial; j++)
                {


                }


            }
        }

        private void objectiveFunctionToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            tabControl1.Visible = true;
        }     
    }
}